var mainHost = "xxx.com";
var redirectUrl = "https://www.baidu.com";

var message = new Array();//消息



$(function(){
    //是否开启调试 cssLib初始化
    log(__OPEN_DEBUG);
    if(__OPEN_DEBUG==="false"){
        //checkHost();
        checkDebug();

        window.onresize = function () {
            checkReSize();
        };

        setTimeout(function(){
            checkReSize();
        }, 300);

        $(document).keydown(function () {
            return forbiddenKeyboard(arguments[0])
        });
    }
});

function redirectPage() {
    //alert("禁止调试，将重定向到："+redirectUrl+"\r\n"+message.join("\r\n"));
    dialogAlert(unescape("%u7981%u6B62%u8C03%u8BD5%uFF0C%u5C06%u91CD%u5B9A%u5411%u5230%uFF1A")+redirectUrl);
    message = null;
    message = new Array();
    setTimeout(function(){
        window.location.href = redirectUrl;
    }, 1500);
    return false
}

function forbiddenKeyboard(o) {
    var r;
    if (window.event) {
        r = o.keyCode
    } else if (o.which) {
        r = o.which
    }
    if (r == 123) { //help: http://www.w3school.com.cn/tiy/t.asp?f=jseg_unescape
        dialogAlert(unescape("%u4EB2%uFF0C%u7981%u6B62%u6309F12%20%u54E6"));
        return false
    }
    if (o.ctrlKey) {
        if (o.shiftKey && r == 73) {
            dialogAlert(unescape("%u4EB2%uFF0C%u7981%u6B62%u6309%20ctrl+shift+I%20%u54E6"));
            return false
        }
    }
    if (o.ctrlKey && r == 83) {
        dialogAlert(unescape("%u4EB2%uFF0C%u7981%u6B62%u6309%20ctrl+s%20%u54E6"));
        return false
    }
}

function checkReSize(){
    if (top.window.outerHeight - top.window.innerHeight > 200) {
        //message.push("open debug because height");
        redirectPage()
    }
    if (top.window.outerWidth - top.window.innerWidth > 200) {
        //message.push("open debug because height");
        redirectPage()
    }
}

function checkHost() {
    var host = window.location.host;
    var domain = document.domain;
    if (host != mainHost || domain != mainHost) {
        message.push("host not:"+mainHost);
        redirectPage();
        return false
    }
}

function checkDebug() {
    if (window.console && (console.firebug || console.table && /firebug/i.test(console.table())) || typeof opera == "object" && typeof opera.postError == "function" && console.profile.length > 0) {
        message.push("firebug");
        redirectPage()
    }
    if (typeof console.profiles == "object" && console.profiles.length > 0) {
        message.push("object");
        redirectPage()
    }
}